<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\DbConnection\Model\Model;
/**
 */
/**
 * @property int $id
 * @property string $username 用户名
 * @property string $password 密码
 * @property string $salt
 * @property string $nickname 昵称
 * @property string $phone 手机号
 * @property string $phone_iv
 * @property string $wechat_code 微信号
 * @property string $profession 职业 0-其他 1-学生 2-上班族
 * @property int $gender 性别 0-未知 1-男 2-女
 * @property string $header_image 头像
 * @property string $email 邮箱
 * @property string $id_number 身份证号
 * @property string $id_number_iv
 * @property \Carbon\Carbon $created_at
 * @property \Carbon\Carbon $updated_at
 */
class User extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'user';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['id', 'username', 'password', 'salt', 'nickname', 'phone', 'phone_iv', 'wechat_code', 'profession', 'gender', 'header_image', 'email', 'id_number', 'id_numer_iv', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'integer', 'gender' => 'integer', 'profession' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function verifyPwd(string $password, string $origin): bool
    {
        if ($password == $origin) {
            return true;
        }
        return false;
    }

    public function changeGender(int $gender): string
    {
        switch ($gender) {
            case 1:
                $text = '男';
                break;
            case 2:
                $text = '女';
                break;
            case 0:
            default:
                $text = '未知';
        }
        return $text;
    }

    public function changeProfession(int $profession): string
    {
        switch ($profession) {
            case 1:
                $text = '学生';
                break;
            case 2:
                $text = '上班族';
                break;
            case 0:
            default:
                $text = '其他';
        }
        return $text;
    }


}
